<?php

namespace Biz\model\SamsungActivity;

use Doraemon\pockets\datebase\BaseDbModel;
use Medoo\Medoo;

class SamsungVoteRecordModel extends BaseDbModel
{

    public const _CONFIG_FILE_ = 'db_store';


    public const _CONFIG_SELECT_ = 'db_brand_activity';

    public const _DATABASE_ = 'brand_activity';


    public const _TABLE_NAME = 'samsung_vote_record';

    const STATUS_NORMAL = 1;
    const STATUS_DELETE = 9;


    const USER_DAY_VOTE_LIMIT = 10; //每个用户每天限投10票
    const ARTWORK_DAY_VOTE_LIMIT = 10000; //每个作品单日最高投票数
    const IP_DAY_VOTE_LIMIT = 1000 ;//每个ip限制单日最高投票数


    public static function insertData($data)
    {
        if (!isset($data['addtime'])) {
            $data['addtime'] = date('Y-m-d H:i:s');
        }
        if (!isset($data['edittime'])) {
            $data['edittime'] = date('Y-m-d H:i:s');
        }
        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }

        return self::id();
    }

    public static function getCountMaps($map)
    {
        return self::select(['cnt' => Medoo::raw('count(obj_id)'), 'obj_id'], $map);
    }

}